package com.example.g7640.util;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class StreamUtil {


    public static <S,D> List<D> convertList(List<S> sourceList, Function<S,D> fun){
        return sourceList.stream().map(fun).collect(Collectors.toList());
    }


    public static <S,D> Map<D,S> listToMap(List<S> sourceList, Function<S,D> fun){
        return sourceList.stream().collect(Collectors.toMap(fun,e->e,(e1,e2)->e1));
    }
}
